﻿using System;
using Microsoft.Xna.Framework;
using RhythmComet.Utils;

namespace FMOD
{
    class RandomBeatDetector : IBeatDetector
    {
        private float timeSinceLastSpawn = 0.0f;
        private float spawnTime = 0.5f;

        #region IBeatDetector Members

        public bool OkToSpawn(GameTime gameTime)
        {
            this.timeSinceLastSpawn += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (this.timeSinceLastSpawn > this.spawnTime)
            {
                this.timeSinceLastSpawn = 0.0f;
                return true;
            }
            return false;
        }

        public bool Beat
        {
            get
            {
                if (RandomGenerator.Random.NextDouble() > 0.5f)
                {
                    return true;
                }
                return false;
            }
        }

        public float Energy
        {
            get { return RandomGenerator.RandomBetween(0.0f, 1.0f); }
        }

        public void Reset()
        {
        }

        public void Update(GameTime gameTime)
        {
        }

        #endregion
    }
}
